package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class GenericDemo {
    public static void main(String[] args) {
        Collection<Point> p=new ArrayList<>();
        p.add(new Point(1,2));
        p.add(new Point(3,4));
        p.add(new Point(5,6));
        p.add(new Point(7,8));

        Iterator<Point> it2=p.iterator();
        while (it2.hasNext()){
            Point a=it2.next();
            System.out.println(a);
        }

        for (Point p1:p){
            System.out.println(p1);
        }






        Collection<String> c1=new ArrayList<>();
        c1.add("asd");
        c1.add("qwe");
        c1.add("zxc");
        c1.add("bnm");
        c1.add("hjk");
        c1.add("yui");

        Iterator<String> it1=c1.iterator();
        while (it1.hasNext()){
            String str=it1.next();
            System.out.println(str);
        }
        for (String str:c1){
            System.out.println(str);
        }



        Collection<String> c=new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");


        Iterator<String> it=c.iterator();
        while (it.hasNext()){
            String str=it.next();
            System.out.println(str);
        }
        for (String str:c){
            System.out.println(str);
        }
    }
}
